<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 班上有五位学生的数据使用 数组来保存 求平均值
        // 1.创建数组
        var scoreArr = [];
        var arr = [];
        var sum = 0;
        var maxValue = 0;
        var minValue = 0;

        // 2.接收学生的成绩
        for (var i = 0; i < 5; i++) {
            scoreArr[i] = prompt("请输入学生的成绩");
        }

        var count = scoreArr.length;

        // 遍历成绩表数组
        for (var i = 0; i < count; i++) {
            // 隐式转化等价于parentInt()
            sum += +scoreArr[i];
            maxValue = +(scoreArr[0]);
            minValue = +(scoreArr[0]);
            if (parseInt(scoreArr[i]) > maxValue) {
                maxValue = parseInt(scoreArr[i]);

            }



            if (parseInt(scoreArr[i]) < minValue) {
                minValue = parseInt(scoreArr[i]);

            }

        }
        console.log("总成绩为：" + sum + ",平均成绩为：" + sum / count);
        console.log(maxValue);
        console.log(minValue);

        console.log(scoreArr);
    </script>
</body>

</html>